import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import router from './router'
import App from './App.vue'

// 引入 Vant
import { 
  Button,
  Tabbar,
  TabbarItem,
  NavBar,
  Icon,
  Search,
  Cell,
  CellGroup,
  Form,
  Field,
  Toast,
  Loading,
  List,
  PullRefresh,
  Popup,
  Dialog,
  Image as VanImage,
  Tag,
  Grid,
  GridItem,
  Swipe,
  SwipeItem,
  Checkbox,
  CheckboxGroup,
  Picker,
  Uploader,
  Tab,
  Tabs,
  Step,
  Steps,
  DatePicker,
  TimePicker,
  PasswordInput,
  NumberKeyboard,
  Empty,
  Switch,
  SwipeCell
} from 'vant'
import '@vant/touch-emulator'
import 'vant/lib/index.css'

// 引入全局样式
import './styles/index.scss'

const app = createApp(App)

// 创建 Pinia 实例
const pinia = createPinia()
// 使用持久化插件
pinia.use(piniaPluginPersistedstate)

// 注册 Vant 组件
const vantComponents = [
  Button,
  Tabbar,
  TabbarItem,
  NavBar,
  Icon,
  Search,
  Cell,
  CellGroup,
  Form,
  Field,
  Toast,
  Loading,
  List,
  PullRefresh,
  Popup,
  Dialog,
  VanImage,
  Tag,
  Grid,
  GridItem,
  Swipe,
  SwipeItem,
  Checkbox,
  CheckboxGroup,
  Picker,
  Uploader,
  Tab,
  Tabs,
  Step,
  Steps,
  DatePicker,
  TimePicker,
  PasswordInput,
  NumberKeyboard,
  Empty,
  Switch,
  SwipeCell
]

vantComponents.forEach(component => app.use(component))

app.use(pinia)
app.use(router)

app.mount('#app')
